﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinFu.AOP.Interfaces;
using CoreEx.DynamicInvoker;
using LinFu.IoC.Configuration;

namespace CoreEx.Common.Implementation.Proxy
{
    [Implements(typeof(IInterceptor),ServiceName = "TargetInjector")]
    public class TargetInjector: IInterceptor
    {
        private object _target;

        public TargetInjector(Func<object> getTarget)
        {
            _target = getTarget();
        }

        public object Intercept(IInvocationInfo info)
        {
            var result = _target.GetType().DynamicInvoke(_target, info.TargetMethod.Name, info.Arguments);
            return result;
            //return info.TargetMethod.DynamicInvoke(_target,info.Arguments);
        }
    }
}
